<div class="login_wrapper">
    <div id="register" class="animate form login_form">
        <section class="login_content">
            <form action="javascript:void(0);">
                <h1>*** Manager System</h1>
                <div>
                    <input name="userName" type="text" class="form-control"
                           placeholder="Username" required="" />
                </div>
                <div>
                    <input name="password" type="password" class="form-control"
                           placeholder="Password" required="" />
                </div>
                <div>
                    <a id="registerButton" class="btn btn-default submit"
                       href="javascript:void(0);">Submit</a>
                </div>

                <div class="clearfix"></div>

                <div class="separator">
                    <p class="change_link">Already a member ?
                        <a href="/account/login" class="to_register"> Log in </a>
                    </p>

                    <div class="clearfix"></div>
                    <br />

                    <div>
                        <h1><i class="fa fa-paw"></i> Hyman Hu</h1>
                        <p>©2016 All Rights Reserved. Create by HymanHu.</p>
                    </div>
                </div>
            </form>
        </section>
    </div>
</div>

<script type="text/javascript">
    //文档加载事件--绑定注册按钮
    $(function () {
        $("#registerButton").bind("click",function(){
            register();
        });
    })
    //注册方法
    function register(){
        var user ={};
        user.userName = $("[name=userName]").val();
        user.password = $("[name=password]").val();
        $.ajax({
            url:"/api/user",
            type:"post",
            //dataType: "application/json",//发送给控制层的数据类型
            contentType: "application/json",
            data:JSON.stringify(user),
            success:function (data) {
                if (data.status==200){
                    location.href="/account/login";
                }else {
                    layer.msg(data.message, {icon: 0});
                }
            },
            error:function (data) {
                layer.msg("ajax请求失败", {icon: 0});
            }
        })
    }
</script>